package com.everyday.practice.leetCode;

public class Title746 {
    public static void main(String[] args) {
        int[] arr=new int[4];
        arr[0]=10;
        arr[1]=15;
        arr[2]=20;
        arr[3]=12;
        System.out.println(min(arr));
    }

    public static int min(int[] cost){
        if (cost.length<=1){
            return 0;
        }else{
            int min0=0;
            int min1=Math.min(cost[0],cost[1]);
            int minTemp=0;
            for(int i=2;i<cost.length;i++){
                minTemp=Math.min(cost[i]+min1,min0+cost[i-1]);
                min0=min1;
                min1=minTemp;
            }
            return minTemp;
        }
    }
}
